using UnityEngine;
using System.Collections;

public class ResourceBarScript : MonoBehaviour {
    public UISlider slider;
    public float maxWidth;

    void Awake()
    {
        slider = GetComponent<UISlider>();

        if (slider == null)
        {
            Debug.LogError("UI Slider was not found");
            return;
        }

        maxWidth = slider.foreground.localScale.x;
    }

    public void UpdateDisplay(float x)
    {
        slider.foreground.localScale = new Vector3((maxWidth * x), slider.foreground.localScale.y, slider.foreground.localScale.z);
    }

	// Use this for initialization
	void Start () 
    {
        UpdateDisplay(.2f);
	}
	
	// Update is called once per frame
	void Update () {
	
	}
}
